
window.onload=function (){
  this.getSwiper();
}


/**
 * 获取轮播图
 */
function getSwiper(){
    $ajax({
        url:swiper_url,
        method:'get',
         success:function (e){
          if(e.code===200){
              const oSwiper=document.getElementById('swiper-wrapper');
              let result=e.banners;
              console.log(result);
              let str = ''
              result.forEach(item => {
                  str += `<div class="swiper-slide">
                        <div>
                             <img alt="加载失败" src=${item.pic}>
                        </div>
                    </div>`
              })
              oSwiper.innerHTML = str;
              new Swiper('.swiper', {
                  loop: true, // 循环模式选项
                  autoplay: true,
                  // 如果需要分页器
                  pagination: {
                      el: '.swiper-pagination',
                  },
                  // 如果需要前进后退按钮
                  navigation: {
                      nextEl: '.swiper-button-next',
                      prevEl: '.swiper-button-prev',
                  }
              })
          }
         }
    })
}

